package com.zheng.damo01.作业;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.function.Consumer;

public class homeWeark02 {
    public static void main(String[] args) {
        Student s1 = new Student("it001", "黄渤", 1.72);
        Student s2 = new Student("it002", "孙红雷", 1.78);
        Student s3 = new Student("it003", "章子怡", 1.64);
        Student s4 = new Student("it004", "杨幂", 1.68);
        ArrayList<Student> list=new ArrayList<>();
        Collections.addAll(list,s1,s2,s3,s4);
        Iterator<Student> it=list.iterator();
        while (it.hasNext()){
            Student next = it.next();
            System.out.println(next);
        }
        System.out.println(list.size());
        System.out.println(list.get(2));
        list.remove(3);
        System.out.println(list);
        Student student=new Student("it005","撒贝宁",1.70);
        list.set(0,student);
        list.forEach(new Consumer<Student>() {
            @Override
            public void accept(Student student) {
                if (student.getHigh()>1.70){
                    System.out.println(student);
                }
            }
        });
        System.out.println(list);
        Iterator<Student> it1=list.iterator();
        while (it1.hasNext()){
            Student s=it1.next();
            if (s.getName().startsWith("孙")){
                System.out.println(s);
            }
        }



    }
}
class  Student{
    private String id;
    private String name;
    private Double High;

    public Student(String id, String name, Double high) {
        this.id = id;
        this.name = name;
        High = high;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", High=" + High +
                '}';
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getHigh() {
        return High;
    }

    public void setHigh(Double high) {
        High = high;
    }
}
